bitkeeper revision 1.22.1.2 (3e3ea191XZbqn2wImmnYu75uh_kNuQ)
authorkaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk>
Mon, 3 Feb 2003 17:06:25 +0000 (17:06 +0000)
committerkaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk>
Mon, 3 Feb 2003 17:06:25 +0000 (17:06 +0000)
mm.h, hypervisor-if.h, memory.c, domain.c:
  Added update interface for the MPT. DOM0 no longer has direct write privileges.

xen-2.4.16/common/domain.c
xen-2.4.16/common/memory.c
xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h
xen-2.4.16/include/xeno/mm.h

index b6279f52fe72efa752a0ee73ef4a8bac60524748..e1ae666f6243437f5a3632083aa484c4dd47949b 100644 (file)
@@ -625,9 +625,6 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params)
     memset(l2tab, 0, DOMAIN_ENTRIES_PER_L2_PAGETABLE*sizeof(l2_pgentry_t));
     p->mm.pagetable = mk_pagetable(phys_l2tab);
 
-    /* Domain 0 gets WRITE access to the read-only machine->physical table. */
-    mk_l2_writeable(l2tab + (READONLY_MPT_VIRT_START >> L2_PAGETABLE_SHIFT));
-
     /*
      * NB. The upper limit on this loop does one extra page + pages for frame
      * table. This is to make sure a pte exists when we want to map the
index ec11ec6e5de107f4cbb9297a11384cdd04620f30..03fa29a2e0f7bfecbb37d0078b24cd08fe8a573c 100644 (file)
@@ -364,12 +364,6 @@ static int get_l2_table(unsigned long page_nr)
               DOMAIN_ENTRIES_PER_L2_PAGETABLE] =
         mk_l2_pgentry(__pa(current->mm.perdomain_pt) | __PAGE_HYPERVISOR);
 
-    /*
-     * DOM0 has the MPT mapped as WRITABLE.
-     * 'p_l2_entry' happens to be pointing at the right place at this point :-)
-     */
-    if ( current->domain == 0 ) mk_l2_writeable(p_l2_entry);
-
  out:
     unmap_domain_mem(p_l2_entry);
     return ret;
@@ -703,9 +697,11 @@ static int do_extended_command(unsigned long ptr, unsigned long val)
     return err;
 }
 
-/* functions to handle page table updates: upper half is invoked in case pt updates
- * are requested by a domain and it invokes copy_from_user. bottom half is invoked
- * both in case of domain downcall and domain building by hypervisor.
+/*
+ * functions to handle page table updates: upper half is invoked in case pt
+ * updates are requested by a domain and it invokes copy_from_user. bottom half
+ * is invoked both in case of domain downcall and domain building by
+ * hypervisor.
  */
 page_update_request_t * do_process_page_updates_uh(page_update_request_t *updates,
     int count)
@@ -742,7 +738,6 @@ int do_process_page_updates_bh(page_update_request_t * cur, int count)
         /* Least significant bits of 'ptr' demux the operation type. */
         switch ( cur->ptr & (sizeof(l1_pgentry_t)-1) )
         {
-
             /*
              * PGREQ_NORMAL: Normal update to any level of page table.
              */
@@ -765,7 +760,14 @@ int do_process_page_updates_bh(page_update_request_t * cur, int count)
                     break;
                 }
             }
+            break;
 
+        case PGREQ_MPT_UPDATE:
+            page = frame_table + pfn;
+            if ( DOMAIN_OKAY(page->flags) )
+            {
+                machine_to_phys_mapping[pfn] = cur->val;
+            }
             break;
 
             /*
index 6052c7b6980b584613ff3b53184ee5963f94fdf7..96826f5afd0aa260324f3c2af16e7bebfb7ddaa5 100644 (file)
@@ -36,8 +36,8 @@ typedef struct
  */
 /* A normal page-table update request. */
 #define PGREQ_NORMAL           0
-/* Make an unchecked update to a base-level pte. */
-#define PGREQ_UNCHECKED_UPDATE 1
+/* Update an entry in the machine->physical mapping table. */
+#define PGREQ_MPT_UPDATE       1
 /* An extended command. */
 #define PGREQ_EXTENDED_COMMAND 2
     unsigned long ptr, val; /* *ptr = val */
@@ -50,6 +50,7 @@ typedef struct
 #define PGEXT_NEW_BASEPTR       5
 #define PGEXT_TLB_FLUSH         6
 #define PGEXT_INVLPG            7
+#define PGEXT_
 #define PGEXT_CMD_MASK        255
 #define PGEXT_CMD_SHIFT         8
 } page_update_request_t;
index 30071e76cfc659c0c25caf7668e10358c65dde74..e60ca748ad88297b0c52cb0eaa9eaa90b7197358 100644 (file)
@@ -114,6 +114,14 @@ extern unsigned int free_pfns;
 extern unsigned long max_page;
 void init_frametable(unsigned long nr_pages);
 
+/*
+ * The MPT (machine->physical mapping table) is an array of word-sized
+ * values, indexed on machine frame number. It is expected that guest OSes
+ * will use it to store a "physical" frame number to give the appearance of
+ * contiguous (or near contiguous) physical memory.
+ */
+#define machine_to_phys_mapping ((unsigned long *)RDWR_MPT_VIRT_START)
+
 /* Part of the domain API. */
 int do_process_page_updates(page_update_request_t *updates, int count);